<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>

        let add = new Proxy({ sum: 0 }, {
            get(target, key, receiver) {
                console.log(key)
                if (key === Symbol.toPrimitive) {
                    let { sum } = target
                    target.sum = 0
                    return () => sum
                }
                target.sum += Number(key)
                return receiver
            }
        })

        console.log(add[1][2][3] + 4)
    </script>
</body>

</html>